import React from "react";
import styled from 'styled-components';
import CommonCard from "@/components/CommonCard/CommonCard";
import { Button, Table, TableColumnProps, Tag } from '@arco-design/web-react';
import { IconInfoCircle } from "@arco-design/web-react/icon";
import OrderJson from "@/configs/order.json";

const Wrapper = styled.div`
    position: relative;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    background: rgb(54, 54, 54);
    padding: 16px;
`;

const ButtonWrapper = styled.div`
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
`;

const OrderManage = () => {

    const columns: TableColumnProps[] = [
        {
            width: '80px',
            title: '序号',
            dataIndex: 'index',
        },
        {
            width: '200px',
            title: '工单编号',
            dataIndex: 'number',
        },
        {
            title: '工单简介',
            dataIndex: 'description',
        },
        {
            width: '150px',
            title: '工单发起人',
            dataIndex: 'creator',
        },
        {
            width: '120px',
            title: '工单状态',
            dataIndex: 'state',
            render: (value, col) => {
                return value === '审批中' ? <Tag  color='#f53f3f' >{ value }</Tag>  : <Tag  color='#7bc616' >{ value }</Tag>
            }
        },
        {
            width: '200px',
            title: '工单创建时间',
            dataIndex: 'createTime',
        },
        {
            width: '250px',
            title: '操作',
            render: (value, col) => {
                return <ButtonWrapper>
                    <Button icon={<IconInfoCircle />} style={{ marginRight: '12px' }}>详情</Button>
                </ButtonWrapper>
            },
        }
    ];

    return (
        <Wrapper>
            <CommonCard
                title="工单管理"
                titleRight={
                    <Button type="primary" style={{ margin: '20px 5px 0px 0px' }}>创建工单</Button>
                }
            >
                <Table style={{ width: '100%' }} columns={columns} rowKey={(row) => row.index} data={OrderJson.data} scroll={{ x: 1200 }}/>;
            </CommonCard>
        </Wrapper>
    )
}


export default OrderManage;